$(function () {
    // 初始化内容
    var basePath = getContextPath();
    $("#channelMenu").attr("class","active");
    $("#breadcrumb").html("绿色通道设置");

    //选择年月日的
    $('#beginTime').datetimepicker({
        format: 'yyyymmdd',
        weekStart: 1,
        autoclose: true,
        startView: 2,
        minView: 2,
        forceParse: false,
        language: 'cn'
    });
    $('#endTime').datetimepicker({
        format: 'yyyymmdd',
        weekStart: 1,
        autoclose: true,
        startView: 2,
        minView: 2,
        forceParse: false,
        language: 'cn'
    });

    $("#myAlert").css('display', 'none');
    $("#btnSubmit").click(function () {
        var accountNo = $("#accountNo").val();
        var beginTime = $("#beginTime").val();
        var endTime = $("#endTime").val();
        var queryType = $("#queryType").val();
        //查询历史
        if (accountNo == null || accountNo == '') {
            $(".noaccount").show();
            return false;
        } else {
            $(".noaccount").hide();
        }
        if (queryType == 1) {
            if (beginTime == "" || beginTime == null) {
                $(".noendTime").show();
                return false;
            } else {
                $(".noendTime").hide();
            }
            if (endTime == "" || endTime == null) {
                $(".noendTime").show();
                return false;
            } else {
                $(".noendTime").hide();
            }

        }
        $("#btnSubmit").text("数据请求中...");
        $("#btnSubmit").attr("disabled","true");
        $.post(basePath + "/back/channel",
            {
                "accountNo": accountNo,
                "beginTime": beginTime,
                "endTime": endTime,
                "queryType": queryType
            },
            function (data) {
                $("#myAlert").css('display', 'block');
                if(data.status=='0002'||data.status=='0001'){
                    $("#alertMsg").html(data.message+":"+data.illegalAccount);
                }else if(data.status=='0003'||data.status=='0004'){
                    $("#alertMsg").html(data.message+":"+data.queryFailAccoNo);
                }else{
                    $("#alertMsg").html(data.message);
                }
                $("#btnSubmit").text("提交");
                $("#btnSubmit").removeAttr("disabled");
            }
        );
    });
});
